from common.setting import ensure_path_sep
from utils.mysqlUtils.db_pool import Database

znkd_db = Database(ensure_path_sep("\\config\\znkd_mysql_config.yaml"), "znkd_database_prod")

class Irobotbox_marketpublish:

    @staticmethod
    def get_active_ordersource_id_list(OrderSourceType):
        get_active_ordersource_id_list = f"""
        select a.OrderSourceId
        from sys_ordersource a
        left join sys_ordersource_authorization b on a.OrderSourceId=b.OrderSourceId
        where a.IsActive=1
        and a.IsDelete=0
        and b.IsActive=1
        and a.OrderSourceType=%s
        """
        res = znkd_db.fetch_all_tuple(get_active_ordersource_id_list,(OrderSourceType,))
        return list(map(lambda x:x[0],res))